package com.cbl.v.ssczs.view.fragment;


import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.GridView;
import android.widget.TextView;

import com.cbl.v.ssczs.R;
import com.cbl.v.ssczs.mode.entity.LocalDataBean;
import com.cbl.v.ssczs.view.adapter.GridAdapter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import butterknife.BindView;

/**
 * A simple {@link Fragment} subclass.
 */
public class OtherFragment extends BaseFragment {
    @BindView(R.id.gv_item)
    GridView gvItem;
    private List<LocalDataBean> beanList;
    private GridAdapter adapter;
    private List<String> titleList;
    private List<String> urlAddressList;
    @Override
    protected int getLayout() {
        return R.layout.fragment_other;
    }

    @Override
    protected void initView(View view) {
        beanList = new ArrayList<>();
        titleList = new ArrayList<>();
        urlAddressList = new ArrayList<>();
        adapter = new GridAdapter(getContext(), beanList);
        gvItem.setAdapter(adapter);beanList = new ArrayList<>();
        titleList = new ArrayList<>();
        urlAddressList = new ArrayList<>();
        adapter = new GridAdapter(getContext(), beanList);
        gvItem.setAdapter(adapter);
        initToolBar(view);
    }
    private void initToolBar(View view) {
        Toolbar toolBar = (Toolbar) view.findViewById(R.id.toolbar);
        TextView title_name = (TextView) view.findViewById(R.id.title_name);
        title_name.setText("开奖汇总");
        toolBar.setTitle("");
        toolBar.setTitleTextColor(Color.WHITE);
    }
    @Override
    protected void initData() {
        getData();
    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void onMyOnclick(View view) {

    }

    private void getData() {
        Collections.addAll(titleList,
                "双色球",
                "七星彩",
                "排列三",
                "排列五",
                "超级大乐透",
                "福彩3D",

                "安徽快三",
                "北京快三",
                "福建快三",
                "甘肃快三",
                "广西快三",
                "贵州快三",
                "河北快三",
                "湖北快三",
                "吉林快三",
                "江苏快三",
                "江西快三",
                "内蒙古快三",
                "上海快三",

                "安徽11选5",
                "北京11选5",
                "福建11选5",
                "广东11选5",
                "甘肃11选5",
                "广西11选5",
                "贵州11选5",
                "河北11选5",
                "湖北11选5",
                "吉林11选5",
                "江苏11选5",
                "江西11选5",
                "辽宁11选5",
                "内蒙古11选5",
                "山东11选5",
                "上海11选5",
                "陕西11选5",
                "山西11选5",
                "天津11选5",
                "新疆11选5",
                "云南11选5",

                "黑龙江时时彩",
                "内蒙古时时彩",
                "天津时时彩",
                "新疆时时彩",
                "云南时时彩");
        Collections.addAll(urlAddressList,
                "http://f.apiplus.net/ssq-20.json",
                "http://f.apiplus.net/qxc-20.json",
                "http://f.apiplus.net/pl3-20.json",
                "http://f.apiplus.net/pl5-20.json",
                "http://f.apiplus.net/dlt-20.json",
                "http://f.apiplus.net/fc3d-20.json",

                "http://f.apiplus.net/ahk3-20.json",
                "http://f.apiplus.net/bjk3-20.json",
                "http://f.apiplus.net/fjk3-20.json",
                "http://f.apiplus.net/gsk3-20.json",
                "http://f.apiplus.net/gxk3-20.json",
                "http://f.apiplus.net/gzk3-20.json",
                "http://f.apiplus.net/hebk3-20.json",
                "http://f.apiplus.net/hubk3-20.json",
                "http://f.apiplus.net/jlk3-20.json",
                "http://f.apiplus.net/jsk3-20.json",
                "http://f.apiplus.net/jxk3-20.json",
                "http://f.apiplus.net/nmgk3-20.json",
                "http://f.apiplus.net/shk3-20.json",


                "http://f.apiplus.net/ah11x5-20.json",
                "http://f.apiplus.net/bj11x5-20.json",
                "http://f.apiplus.net/fj11x5-20.json",
                "http://f.apiplus.net/gd11x5-20.json",
                "http://f.apiplus.net/gs11x5-20.json",
                "http://f.apiplus.net/gx11x5-20.json",
                "http://f.apiplus.net/gz11x5-20.json",
                "http://f.apiplus.net/heb11x5-20.json",
                "http://f.apiplus.net/hub11x5-20.json",
                "http://f.apiplus.net/jl11x5-20.json",
                "http://f.apiplus.net/js11x5-20.json",
                "http://f.apiplus.net/jx11x5-20.json",
                "http://f.apiplus.net/ln11x5-20.json",
                "http://f.apiplus.net/nmg11x5-20.json",
                "http://f.apiplus.net/sd11x5-20.json",
                "http://f.apiplus.net/sh11x5-20.json",
                "http://f.apiplus.net/sxl11x5-20.json",
                "http://f.apiplus.net/sxr11x5-20.json",
                "http://f.apiplus.net/tj11x5-20.json",
                "http://f.apiplus.net/xj11x5-20.json",
                "http://f.apiplus.net/yn11x5-20.json",

                "http://f.apiplus.net/hljssc-20.json",
                "http://f.apiplus.net/nmgssc-20.json",
                "http://f.apiplus.net/tjssc-20.json",
                "http://f.apiplus.net/xjssc-20.json",
                "http://f.apiplus.net/ynssc-20.json"
        );
        for (int i = 0; i < titleList.size(); i++) {
            LocalDataBean bean = new LocalDataBean();
            String title=titleList.get(i);
            if (title.equals("双色球")){
                bean.setType("双色球");
                bean.setIcon(R.mipmap.ic_ssq);
            }else if (title.equals("七星彩")){
                bean.setIcon(R.mipmap.ic_qxc);
            }else if (title.equals("排列三")){
                bean.setIcon(R.mipmap.ic_pl3);
            }else if (title.equals("排列五")){
                bean.setIcon(R.mipmap.ic_pl5);
            }else if (title.equals("超级大乐透")){
                bean.setType("大乐透");
                bean.setIcon(R.mipmap.ic_dlt);
            }else if (title.equals("福彩3D")){
                bean.setIcon(R.mipmap.ic_3d);
            }else if (title.contains("快三")){
                bean.setIcon(R.mipmap.ic_ks);
            }else if (title.contains("11选5")){
                bean.setIcon(R.mipmap.ic_11x5);
            }else if (title.contains("时时彩")){
                bean.setIcon(R.mipmap.ic_ssc);
            }
            bean.setTitle(titleList.get(i));
            bean.setUrlAddress(urlAddressList.get(i));

            beanList.add(bean);
        }
        adapter.notifyDataSetChanged();
    }

}
